home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / vgaprtsc.zip / VGAPRTSC.ASM < prev    next >
Assembly Source File  |  1989-02-24  |  10KB  |  394 lines

  1. ;       ***********************************************************
  2. ;
  3. ;              VGAPRTSC.ASM   ver 1.3   February 1989
  4. ;
  5. ;           Hardcopy Utility for VGA-(and EGA-) Graphics Modes
  6. ;
  7. ;                          Robert Kaempf
  8. ;                         <DB3D@DDATHD21>
  9. ;                     Institut fuer Kernphysik
  10. ;                  Technische Hochschule Darmstadt
  11. ;                    6100 Darmstadt, West Germany
  12. ;
  13. ;       ***********************************************************
  14. ;
  15. ;       VGAPRTSC is similar to the MSDOS program GRAPHICS.COM.
  16. ;       The difference is: GRAPHICS supports low resolution
  17. ;       graphics modes (320x200,640x200), VGAPRTSC supports high
  18. ;       resolution graphics modes (640x480,640x350).
  19. ;       Text or low resolution graphics modes cause a call to the
  20. ;       old hardcopy routine. It is possible to install GRAPHICS
  21. ;       before VGAPRTSC. This will support any graphics modes.
  22. ;
  23. ;       Parameter:
  24. ;       /C= followed by 16 digits
  25. ;       The 16 digits correspond to the 16 screen colors.
  26. ;       An odd digit selects the color to be printed,
  27. ;       colors with even digits are not printed.
  28. ;
  29. ;       Example:
  30. ;       VGAPRTSC /C=0111111111111111   ( default )
  31. ;          prints colors 1 to 15.
  32. ;       VGAPRTSC /C=0000222211113333
  33. ;          prints highlighted colors ( 8 to 15 )
  34. ;
  35. ;       You may modify the colortable of an installed VGAPRTSC
  36. ;       version by typing: VGAPRTSC /C=... .
  37. ;       VGAPRTSC will not be installed twice !
  38. ;
  39. ;       Make VGAPRTSC.COM using MASM, LINK, EXE2BIN.
  40. ;
  41.  
  42. ESC     equ   1bh
  43. CR      equ   0dh
  44. LF      equ   0ah
  45.  
  46. disp    macro string
  47.         lea   dx,string
  48.         mov   ah,09h
  49.         int   21h
  50.         endm
  51.  
  52. _code   segment
  53.         assume cs:_code,ds:_code
  54.         org   100h
  55. start:  jmp inst
  56.  
  57. logo    db "VGAPRTSC (c) Robert Kaempf"
  58. logoend db 13,10,13,10,"$"
  59. oldss   dw 0
  60. oldsp   dw 0
  61. int5old dd 0
  62. used    db 0
  63. pbyte   db 0
  64. ymax    dw 0
  65. pcount  dw 1
  66. colors  db 0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1
  67. ini6lpi db 5,esc,"A",12,esc,"2"  ; 6 lpi = 12/72 inch pro LF
  68. ini9lpi db 5,esc,"A",08,esc,"2"  ; 9 lpi =  8/72 inch pro LF
  69. inigrx  db 5,esc,"*"
  70. grxden  db 0
  71. grxlo   db 0
  72. grxhi   db 0
  73.  
  74. jmptbl  dw offset dummy   ; graphmode 0
  75.         dw offset dummy   ; graphmode 1
  76.         dw offset dummy   ; graphmode 2
  77.         dw offset dummy   ; graphmode 3
  78.         dw offset dummy   ; graphmode 4
  79.         dw offset dummy   ; graphmode 5
  80.         dw offset dummy   ; graphmode 6
  81.         dw offset dummy   ; graphmode 7
  82.         dw offset dummy   ; graphmode 8
  83.         dw offset dummy   ; graphmode 9
  84.         dw offset dummy   ; graphmode a
  85.         dw offset dummy   ; graphmode b
  86.         dw offset dummy   ; graphmode c
  87.         dw offset dummy   ; graphmode d
  88.         dw offset dummy   ; graphmode e
  89.         dw offset egapr   ; graphmode f
  90.         dw offset egapr   ; graphmode 10
  91.         dw offset vgapr   ; graphmode 11
  92.         dw offset vgapr   ; graphmode 12
  93.  
  94. stack   db 100h dup ("TheStack")
  95. tosta   db 0
  96.  
  97. beep    proc near
  98.         push ax
  99.         push cx
  100.         in al,61h
  101.         or al,03h
  102.         out 61h,al
  103.         mov cx,6000h
  104.         loop $
  105.         and al,11111100b
  106.         out 61h,al
  107.         pop cx
  108.         pop ax
  109.         ret
  110. beep    endp
  111.  
  112. prt_al  proc   near         ; send al to LPT1
  113.         push   ax
  114.         push   dx
  115.         mov    dx,0
  116.         mov    ah,0
  117.         int    17h
  118.         pop    dx
  119.         pop    ax
  120.         ret
  121. prt_al  endp
  122.  
  123. prtstr  proc   near         ; print string DS:DX
  124.         push   si           ; [DS:DX+0] = length
  125.         push   bp
  126.         push   cx
  127.         push   ax
  128.         mov    bp,dx
  129.         mov    si,0
  130.         xor    cx,cx
  131.         mov    cl,ds:byte ptr [bp]
  132.  
  133. psloop: inc    si
  134.         cmp    si,cx
  135.         ja     psexit
  136.         mov    al,ds:byte ptr [bp][si]
  137.         call   prt_al
  138.         jmp    psloop
  139. psexit: pop    ax
  140.         pop    cx
  141.         pop    bp
  142.         pop    si
  143.         ret
  144. prtstr  endp
  145.  
  146. dummy   proc   near
  147.         pushf                      ; int5old uses iret, needs flags
  148.         call   dword ptr int5old   ; it's a far call
  149.         ret
  150. dummy   endp
  151.  
  152. hardcp  proc   near
  153. ; uses  grxinit, ymax, pcount, colors
  154.         mov    dx,offset ini9lpi
  155.         call   prtstr
  156.  
  157.         mov    cx,80
  158. loopx:  push   cx
  159. ;        call   beep                ; helpful using lpt2dsk
  160.  
  161.         mov    dx,offset inigrx    ; start graphics line
  162.         call   prtstr
  163.  
  164.         mov    dx,cx
  165.         dec    dx
  166.         mov    cl,3
  167.         shl    dx,cl               ; x-pixel base
  168.  
  169.         mov    bx,0h               ; y-pixel
  170. loopy:  mov    byte ptr pbyte,00h  ; claer printer byte
  171.  
  172.         mov    cx,08h              ; 8 pixel for printer
  173. loop8:  push   cx
  174.         push   dx
  175.         push   bx
  176.         push   di
  177.  
  178.         dec    cx
  179.         add    cx,dx               ; x = cx
  180.         mov    dx,bx               ; y = dx
  181.         mov    ah,0dh              ; getcolor
  182.         mov    bh,00h              ; page 1
  183.         int    10h
  184.  
  185.         sal    byte ptr pbyte,01h
  186.         mov    di,ax
  187.         and    di,00ffh
  188.         mov    bl,[offset colors + di]
  189.         or     byte ptr pbyte,bl
  190.  
  191.         pop    di
  192.         pop    bx
  193.         pop    dx
  194.         pop    cx
  195.         loop   loop8
  196.  
  197.         mov    cx,pcount
  198. ploop:  mov    al,pbyte
  199.         call   prt_al
  200.         loop   ploop
  201.  
  202.         inc    bx
  203.         cmp    bx,ymax
  204.         jb     loopy
  205.  
  206.         mov    al,cr               ; CR,LF
  207.         call   prt_al
  208.         mov    al,lf
  209.         call   prt_al
  210.         pop    cx
  211.         loop   loopx
  212.  
  213.         mov    dx,offset ini6lpi
  214.         call   prtstr
  215.         ret
  216. hardcp  endp
  217.  
  218. vgapr   proc   near                ; VGA hardcopy
  219.         mov    dx,480
  220.         mov    ymax,dx
  221.         mov    word ptr pcount,01h
  222.         mov    grxlo,dl
  223.         mov    grxhi,dh            ; length of printerline
  224.         mov    byte ptr grxden,00h ; use 05h for Olivetti PR17B
  225.         jmp    hardcp
  226. vgapr   endp
  227.  
  228. egapr   proc   near                ; EGA hardcopy
  229.         mov    dx,350
  230.         mov    ymax,dx
  231.         mov    word ptr pcount,02h ; print bytes twice
  232.         add    dx,dx               ; print bytes twice
  233.         mov    grxlo,dl
  234.         mov    grxhi,dh            ; length of printerline
  235.         mov    byte ptr grxden,01h ; use 06h for Olivetti PR17B
  236.         jmp    hardcp
  237. egapr   endp
  238.  
  239. int5    proc   near
  240.  
  241.         cli
  242.         push   ax
  243.         mov    oldss,ss
  244.         mov    oldsp,sp
  245.         mov    ax,cs
  246.         mov    ss,ax
  247.         mov    sp,offset tosta
  248.         sti
  249.  
  250.         push   ds
  251.         push   dx
  252.         push   cx
  253.         push   bx
  254.  
  255.         push   cs
  256.         pop    ds
  257.  
  258.         or     byte ptr used,00h    ; flag
  259.         jnz    int5ex               ; vgaprtsc is running, exit
  260.  
  261.         mov    ah,0fh               ; get VGA mode
  262.         int    10h
  263.         cmp    al,12h
  264.         ja     int5ex               ; mode >12h not used
  265.  
  266.         mov    used,01h             ; set prtsc flag
  267.         xor    ah,ah                ;
  268.         shl    ax,1                 ; make word index
  269.         mov    bx,offset jmptbl
  270.         add    bx,ax
  271.         call   ds:[bx]
  272.         mov    used,00h
  273.  
  274. int5ex:
  275.         pop    bx
  276.         pop    cx
  277.         pop    dx
  278.         pop    ds
  279.  
  280.         cli
  281.         mov    ss,oldss
  282.         mov    sp,oldsp
  283.         pop    ax
  284.         sti
  285.  
  286.         iret
  287. int5    endp
  288.  
  289. inst:   push   cs
  290.         pop    ds
  291.         disp   logo
  292.  
  293.         mov    ax,3505h         ; get int5 vektor -> es:bx
  294.         int    21h
  295.         cmp    bx,offset int5
  296.         jnz    i1               ; different ? yes -> install
  297.         lea    si,logo          ; maybe installed ?
  298.         lea    di,logo          ; check logo
  299.         lea    cx,logoend
  300.         sub    cx,offset logo   ; length of logo
  301.         cld
  302.         repz   cmpsb            ; compare  ds:si  with es:di
  303.         jnz    i1               ; different ? yes -> install
  304.  
  305.         call   lineop           ; ES: Segment of old VGAPRTSC
  306.         disp   notdb